package com.bonc.ioc.service.impl;//package com.bonc.ioc.web.services;


import com.bonc.ioc.base.page.PageResult;
import com.bonc.ioc.base.service.BaseService;
import com.bonc.ioc.dao.DemoDao;
import com.bonc.ioc.model.Demo;
import com.bonc.ioc.service.IDemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindException;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @author ：liyy
 * @date ：Created in 2020/3/24 17:25
 * @description：
 * @modified By：
 * @version: V1.0
 */
@Service
public class DemoServiceImpl extends BaseService implements IDemoService {

    @Resource
    private DemoDao demoDao;

    @Autowired
    private RedisTemplate redisTemplate;



    @Override
    public PageResult selectDemosByPage(String parm1, String parm2) throws BindException {
        HashMap<String, Object> map= this.getPageParams();
        map.put("parm1",parm1);
        map.put("parm2",parm2);
        return new PageResult(map,demoDao.selectDemosByPage(map));
    }

    @Override
    public Integer save(Demo demo) {
        return demoDao.save(demo);
    }

    @Override
    public void setToRedis(String key, String value) {
        redisTemplate.opsForValue().set(key,value);
    }

    @Override
    public Object getFromRedis(String key) {
        return redisTemplate.opsForValue().get(key);
    }


}
